package net.wangds.utils;

import net.wangds.iocomp.utils.StreamUtils;
import net.wangds.log.helper.LogHelper;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class ServletUtils {

    public static String readRequestBody(HttpServletRequest req){
        if(req==null){
            return "";
        }

        try {
            return StreamUtils.readAsString(req.getInputStream(), req.getCharacterEncoding());
        } catch (IOException e) {
            LogHelper.error(e);
        }
        return "";
    }

}
